package com.example.warehousems.event.listener;

import com.example.warehousems.event.event.CargoInEvent;
import com.example.warehousems.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class CargoInListener implements ApplicationListener<CargoInEvent> {
    @Autowired
    private WarehouseService warehouseService;
    @Override
    public void onApplicationEvent(CargoInEvent event) {
        warehouseService.putCargoIntoStorage(event.getCargo());
        System.out.println(event);
    }
}
